package cn.com.fssg.platform.base.handler.impl.gsl.lz;

import cn.com.fssg.platform.base.handler.InterfaceHandler;
import cn.com.fssg.platform.biz.BizUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 我的商协会查询表单数据
 */
@Component
public class MyBusiness implements InterfaceHandler {

//    @Autowired
//    private NamedParameterJdbcTemplate jdbcTemplate;
    private NamedParameterJdbcTemplate jdbcTemplate = BizUtil.cur().tenantMainJdbcTemplate();

    @Override
    public Object run(HttpServletRequest request, JSONObject jsonObject) throws Exception {
        HashMap<String, Object> params = new HashMap<>();
        params.put("createBy", "%"+BizUtil.cur().curUserId()+"%");
        String sql = "select * from gsl_sxhxx where user_ids like :createBy order by create_date desc limit 1";
        return jdbcTemplate.queryForMap(sql, params);
        /*List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, params);
        if(!list.isEmpty()){
            Map<String, Object> map = list.get(0);
            return map;
        }
        return new HashMap<>();*/
    }
}
